import re

'''
https://product.suning.com/0070087672/620021273.html
https://product.suning.com/0000000000/129470093.html
'''


def update_suning_sku(smzdm):
    mall_code = ''
    commodity_code = ''
    m = re.search(r'\|2F(\d{10})\|', smzdm.remark)
    if m:
        mall_code = m.group(1)
    m = re.search(r'\|2F(\d{9})\|', smzdm.remark)
    if m:
        commodity_code = m.group(1)
    if len(mall_code) > 0 and len(commodity_code) > 0:
        smzdm.commodity_sku = '%s|%s' %(mall_code, commodity_code)
        smzdm.mall_url = 'https://product.suning.com/%s/%s.html' %(mall_code, commodity_code)
        smzdm.active = True
    else:
        smzdm.active = False
    m = re.search(r'\|2F(\d{13,18})\|', smzdm.remark) # http://product.suning.com/0000000000/000000000125055797.html
    if not smzdm.active and m:
        smzdm.commodity_sku = '%s|%s' %(mall_code, m.group(1))
        smzdm.mall_url = 'https://product.suning.com/%s/%s.html' %(mall_code, m.group(1))
        smzdm.active = True
    return smzdm

def update_suning_haiwai(smzdm):
    return smzdm
